import { ref } from 'vue'
import {
  getAnchorSwiper,
  getCategoryNav,
  getRecommd,
  getPays,
  getTypeAnchors
} from '@/service/find-music/anchor-station'

export function InitGetData() {
  //获取轮播图数据
  const swipers = ref(null)
  getAnchorSwiper().then((res: any) => {
    swipers.value = res.data
  })
  //获取导航分类图标数据
  const cateList = ref([])
  getCategoryNav().then((res: any) => {
    cateList.value = res.categories.splice(0, 5)
  })
  //获取精选电台数据
  const recommends = ref([])
  const recommend = ref([])
  getRecommd().then((res: any) => {
    recommends.value = res.djRadios
    const arr = [...recommends.value]
    recommends.value = recommends.value.splice(0, 4)
    arr.splice(0, 4)
    recommend.value = [...arr]
  })
  // 付费电台
  const pays = ref([])
  getPays().then((res: any) => {
    pays.value = res.data.list
  })
  // 不同类型电台数据
  function getType(typeid: number, data: any, num: number) {
    getTypeAnchors(typeid).then((res: any) => {
      data.value = res.djRadios.splice(0, num)
    })
  }
  // 创作翻唱电台
  const creations = ref([])
  getType(2001, creations, 6)
  // 3D电子电台
  const electrs = ref([])
  getType(10002, electrs, 6)
  // 音乐故事
  const musicStory = ref([])
  getType(2, musicStory, 6)
  // 情感调频
  const emotion = ref([])
  getType(3, emotion, 6)
  // 二次元
  const quadratic = ref([])
  getType(3001, quadratic, 6)

  return [
    swipers,
    cateList,
    recommends,
    recommend,
    pays,
    creations,
    electrs,
    musicStory,
    emotion,
    quadratic
  ]
}
